import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';

void configEasyLoading() {
  EasyLoading.instance
    ..displayDuration = const Duration(milliseconds: 1000)
    ..indicatorType = EasyLoadingIndicatorType.fadingCircle
    ..loadingStyle = EasyLoadingStyle.custom
    ..backgroundColor = Colors.black.withOpacity(0.5)
    ..indicatorColor = Colors.white
    ..textColor = Colors.white
    ..maskType = EasyLoadingMaskType.clear
    ..maskColor = Colors.black.withOpacity(0.5)
    ..progressColor = Colors.white
    ..dismissOnTap = false;
}

void showToast(String text,
    {Duration? duration, toastPosition = EasyLoadingToastPosition.center}) {
  if(text==null||text.isEmpty){
    return;
  }
  EasyLoading.showToast(text, toastPosition: toastPosition, duration: duration);
}

void showLoading(
    {String? status, EasyLoadingMaskType maskType = EasyLoadingMaskType.clear}) {
  EasyLoading.show(status: status, maskType: maskType);
}

void hideLoading() {
  EasyLoading.dismiss();
}

void showSuccess(String text, {Duration? duration}) {
  EasyLoading.showSuccess(text, duration: duration);
}
